/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ove.openmath.jome.ctrlview.bidim;

/**
 *
 * @author Mr.Sam
 */
import java.awt.*;
import fr.ove.openmath.jome.ctrlview.bidim.*;

/**
* This layout manager lays postfixed unary operators.
*
* @author © 1999 DIRAT Laurent
* @version 2.0  13/12/1999
*/
public abstract class PostfixedUnaryOperatorLayout extends UnaryOperatorLayout {
    /**
    * Computes the size of the display according to its children size (if any),
    * and its different attributes.
    * @return the size of the display.
    */
    public Dimension computeAttributes() {
        Display dOperator = (Display) displayToLay.getComponent(0);
        Display dOperand = (Display) displayToLay.getComponent(1);
        
        // Initialisation des shift* pour ne pas introduire de faux paramètres.
        dOperator.setAttributes(dOperator.getAscent(), dOperator.getDescent(), 0, 0);
        dOperand.setAttributes(dOperand.getAscent(), dOperand.getDescent(), 0, 0);
        
        // Calcul des attributs de manière classique...
        Dimension dim = super.computeAttributes();
        
        // ...sauf que l'opérateur, il faut le faire passer derrière
        dOperator.setShiftX(dim.width - dOperator.getWidth());
        dOperand.setShiftX(-dOperator.getShiftX() - dOperator.getWidth());
        
        return dim;
    }
}
